<template>
  <!-- 注意：添加v-if="goodsInfo"，如果为空不渲染 -->
  <div class="base-info" v-if="goodsInfo">
    <h2 class="title">{{ goodsInfo.title }}</h2>
    <div class="price">
      <span class="lowNowPrice">¥{{ goodsInfo.lowNowPrice }}</span>
      <span class="oldPrice">{{ goodsInfo.oldPrice }}</span>
      <span
        class="discountDesc"
        :style="'background-color:' + goodsInfo.discountBgColor"
        v-if="goodsInfo.discountDesc"
        >{{ goodsInfo.discountDesc }}</span
      >
    </div>
    <div class="columns" v-if="goodsInfo.columns">
      <span>{{ goodsInfo.columns[0] }}</span>
      <span>{{ goodsInfo.columns[1] }}</span>
    </div>
    <div class="services">
      <div
        class="services-item"
        v-for="item in goodsInfo.services"
        :key="item.name"
      >
        <img :src="item.icon" alt="" />
        <span>{{ item.name }}</span>
      </div>
    </div>
  </div>
</template>

<script>
export default {
  props: {
    goodsInfo: {
      type: Object,
      default() {
        return {};
      },
    },
  },
};
</script>

<style lang="less" scoped>
.base-info {
  padding: 10px;
  .title {
    font-size: 20px;
    font-weight: 500;
    color: #333;
  }
  .price {
    margin: 10px 0 5px 0;
    .lowNowPrice {
      color: #f13e3a;
      font-size: 24px;
      font-weight: 500;
    }
    .oldPrice {
      margin: 0 10px;
    }
    .discountDesc {
      position: relative;
      top: -5px;
      color: #fff;
      padding: 2px 5px;
      border-radius: 10px;
      font-size: 14px;
    }
  }
  .columns {
    display: flex;
    margin-bottom: 6px;
    span {
      flex: 1;
    }
  }
  .services {
    display: flex;
    flex-wrap: wrap;
    font-size: 12px;
    padding: 8px 0;
    border-top: 2px solid #eee;
    border-bottom: 2px solid #eee;
    .services-item {
      width: 33.33%;
    }
    img {
      width: 12px;
      height: 12px;
      vertical-align: -2px;
      margin-right: 2px;
    }
  }
}
</style>
